package com.javajun.endofterm.entity;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author: Xiong Limin
 * Date: 2020-11-30-8:35 下午
 */
@Entity
public class Student extends SysUser{

    @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH})
    @JoinColumn
    @NotFound(action= NotFoundAction.IGNORE)
    private Domitory domitory;


    public Domitory getDomitory() {
        return domitory;
    }

    private String department; //院系
    private String majorClazz; //专业,班级

    /**
     * 获取宿舍名,不持久化
     * @return
     */
    @Transient
    public String getDomitoryName() {
        String str = "";
        if (domitory != null) {
            str = domitory.getName();
        }
        return str;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getMajorClazz() {
        return majorClazz;
    }

    public void setMajorClazz(String majorClazz) {
        this.majorClazz = majorClazz;
    }

    public void setDomitory(Domitory domitory) {
        this.domitory = domitory;
    }
}
